<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
	<style type="text/css">
		body, html {width: 100%;height: 100%;margin:0;font-family:"微软雅黑";font-family:"微软雅黑";}
		#allmap{width:100%;height:500px;}
		p{margin-left:5px; font-size:14px;}
	</style>
	<?php 

		include ('application/classes/config/sysconfig.php');
		$config = new sysconfig();
	?>

<script src="<?php echo Url::base();?>jquery.min.js" type="text/javascript"></script>
	<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=<?php echo $config->mapAk; ?>"></script>
	<title>地图单击事件</title>
</head>
<body>
<form  method="post" action="<?php echo Url::base(); ?>index.php/storem/updatestore?">
	城市选择:
		<select name="province"  id="province" onchange="getCity(this)">
			<?php foreach($china  as $key=>$val){

				if($val['Name']=="中国"){
					continue;
				}

				?>


			<option <?php if($store[0]['province']==$val['Id']){ ?>selected<?php }?> value="<?php  echo $val['Id'];?>"><?php  echo $val['Name'];?></option>
			<?php } ?>
		</select>

		<select id="city" name="city">

		</select><br>
		
	<input type="hidden" value="<?php echo $_REQUEST['id'];?>"  name="id"/>
		地址:<input type="text" name="address" value="<?php echo $store[0]['address'];?>" /><br>
		联系人:<input type="text" name="contact"  value="<?php echo $store[0]['contact'];?>"/><br>
		经度:<input type="text" name="longitude" id="longitude" value="<?php echo $store[0]['longitude'];?>" /><br>

		纬度:<input type="text" name="latitude" id="latitude" value="<?php echo $store[0]['latitude'];?>" /><br>
		联系电话:<input type="text" name="phone"  value="<?php echo $store[0]['phone'];?>"  /><br>
		门店是否自提:<input type="radio" <?php if($store[0]['isget']==0){?>checked<?php }?> name="isget" value="0"/>不支持 <input  <?php if($store[0]['isget']==1){?>checked<?php }?>  name="isget"  type="radio" value="1"/>支持<br>
		门店是否配送:<input type="radio" <?php if($store[0]['isstore']==0){?>checked<?php }?>  name="isstore" value="0"/>不支持 <input <?php if($store[0]['isstore']==1){?>checked<?php }?>   name="isstore"  type="radio" value="1"/>支持 
	<div id="allmap"></div>
	<p>添加点击地图监听事件，点击地图后显示当前经纬度</p>
	<input  type="submit"/>
	</form>
</body>
</html>
<script type="text/javascript">
	function getData(id){
		$.ajax({

				type: 'POST',
				url: '<?php echo Url::base(); ?>index.php/chinam/getCity?id='+ id,
				success: function(data){
					console.log(data);
					$("#city").html("")
					var size =  data.length;
					for(var i = 0; i < size;i++){
						var varItem = new Option(data[i].Name,data[i].Id);
						document.getElementById("city").options.add(varItem);
					}
				} ,
				dataType: "json"

			});
	}
	function getCity(obj){
		getData($(obj).val())
			
	}
	console.log()
	getData(<?php echo $store[0]['province'];?>)
	// 百度地图API功能
	var map = new BMap.Map("allmap");
	map.centerAndZoom(new BMap.Point(116.404, 39.915), 11);
	function showInfo(e){
		$("#latitude").val(e.point.lat);
		$("#longitude").val(e.point.lng);
	}
	map.enableScrollWheelZoom(true);     //开启鼠标滚轮缩放
	map.addEventListener("click", showInfo);
</script>
